import type { FieldConfig } from '@/components/TableFilter.vue'
import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '標題',
    dataIndex: 'title',
  },
  {
    title: '內容',
    dataIndex: 'content',
  },
  {
    title: '消息類型',
    dataIndex: 'type',
  },
  {
    title: '消息狀態',
    dataIndex: 'messageStatus',
  },
  {
    title: '處理人',
    dataIndex: 'handler',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'message_status',
    label: '消息狀態',
    type: 'select',
    options: [
      { value: '', label: '全部' },
      { value: '2', label: '無需處理' },
      { value: '1', label: '已處理' },
      { value: '0', label: '未處理' },
    ],
  },
  {
    name: 'type',
    label: '消息類型',
    type: 'select',
    options: [
      { value: '', label: '全部' },
      { value: '1', label: '處理' },
      { value: '2', label: '通知' },
    ],
  },
]

// 表單字段配置
const FormField: Record<string, FormFieldConfig> = {
  message_status: {
    label: '消息狀態',
    type: 'select',
    placeholder: '請選擇消息狀態',
    rules: [{ required: true, message: '請選擇消息狀態' }],
    options: [
      { key: '0', label: '未處理' },
      { key: '1', label: '已處理' },
    ],
  },
}

// 創建表單字段
// export const getCreateFieldConfig = (fields?: string[]) => {
//   return getFormFields(FormField, fields)
// }

export const getEditFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}
